/*
 * Copyright 2014 Rivaldo.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.jety.client;

import org.jety.client.transport.HttpClientTransport;
import org.jety.commons.domain.ProxyBuilder;

/**
 * Invoker for the client call the server objects.
 * @author Rivaldo
 */
public class Invoker {

    /**
     * Get a proxy object to acess the server remote object.
     * @param <T> the object class type
     * @param objectID the name of the server handle object
     * @param transport the transport to acess the server
     * @param classes the interfaces implemented by the object
     * @return a proxy instance to the remote object
     * @throws IllegalArgumentException erro while creating the proxy
     */
    public <T> T lookup(final String objectID, final HttpClientTransport transport, final Class<T>... classes) throws IllegalArgumentException {
        InvokeHandler handler = new InvokeHandler(objectID, transport);
        return ProxyBuilder.createProxy(handler, classes);
    }

}
